package com.test.pattern.command;

import java.util.Map;

/**
 * @ClassName: OrderCommand
 * @description: 具体命令类
 * @author: Mr du
 * @create: 2024-03-05 23:08
 */
public class OrderCommand  implements Command {

    //持有接收者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable()+"号桌订餐!");
        //从订单中获取要制作的菜品交给厨师制作
        Map<String, Integer> map = order.getFoodDir();
        for (Map.Entry<String,Integer> entry : map.entrySet()){
            receiver.makeFood(entry.getValue(), entry.getKey());
        }

        System.out.println(order.getDiningTable() + "桌的饭弄好了");
    }
}
